package myorg.myrpc;

/**
 * client端和服务端共用的基本类型常量定义
 * @author unknow_author
 *
 */
public interface CommonConstant {
    public static final int NULL_ID_INTEGER = -1;
    /** 字符串型主键的{@code null} 替代值 */
    public static final String NULL_ID_STRING = "";
    /** 默认服务端口号 */
    public static final int DEFAULT_PORT = 28081;
    /** 默认XHR(XML Http Request)服务端口号 */
    public static final int DEFAULT_PORT_XHR = 28082;
    /** 默认RESTful服务端口号 */
    public static final int DEFAULT_PORT_RESTFUL = 8080;
    /** ISO8601时间格式 */
    public static final String ISO8601_FORMATTER_STR = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
    
    /** 用于SQL语句的时间戳格式转换格式 */
    public static final String TIMESTAMP_FORMATTER_STR = "yyyy-MM-dd HH:mm:ss";
    
    /** 时间转换格式 */
    public static final String DATE_FORMATTER_STR = "yyyy-MM-dd";
    
    /**
     * 服务异常类型定义
     */
    public static enum ExceptionType{
        /** 其他未分类异常 */
        UNCLASSIFIED,
        /** 数据库访问异常 */
        DAO,
        /** redis 服务器异常 */
        REDIS_ERROR,
        /** RuntimeException */
        RUNTIME,
        /** 图像数据异常 */
        IMAGE_ERROR,
        /** 安全异常 ServiceSecurityException */
        SECURITY_ERROR
    }
    
    
    ///////////// COMMONS PROPERTY KEY DEFINITION ///////////
    
    /** root 用户密码 */
    public static final String ROOT_PASSWORD = "root.password";
    
    /** Thrift服务端是否启动 */
    public static final String SERVER_START = "server.start";
    
    /** Thrift服务端口号 */
    public static final String SERVER_PORT = "server.port";
    
    /** 最大连接数 */
    public static final String SERVER_CONNECTION_LIMIT = "server.connectiontLimit";
    
    /** 空闲连接超时(秒) */
    public static final String SERVER_IDLE_CONNECTION_TIMEMOUT = "server.idleConnectionTimeout";
    
    /** 工作线程数 */
    public static final String SERVER_WORKER_THREAD_COUNT ="server.workerThreadCount";

    /** XHR(XML HTTP Request)服务参数配置:XHR服务端是否启动 */
    public static final String XHR_START = "xhr.start";
    
    /** XHR(XML HTTP Request)服务参数配置:XHR服务端口,默认值{@value #DEFAULT_PORT_XHR} */
    public static final String XHR_PORT = "xhr.port";

    /** RESTful web服务参数配置:RESTful 服务端是否启动 */
    public static final String RESTFUL_START = "restful.start";
    
    /** RESTful web服务参数配置:RESTful服务端口,默认值{@value #DEFAULT_PORT_RESTFUL} */
    public static final String RESTFUL_PORT = "restful.port";
    
    /** RESTful web服务参数配置:是否显示在线swagger文档,默认值{@code true} */
    public static final String RESTFUL_SWAGGER_ENABLE = "restful.swaggerEnable";
    
    /** RESTful web服务参数配置:是否支持跨域访问(CORS),默认值{@code true} */
    public static final String RESTFUL_CORS_ENABLE = "restful.corsEnable";
    
    /** 通用线程池:最小线程数量,默认为CPU逻辑核数 */
    public static final String EXECUTOR_CACHEDPOOL_COREPOOLSIZE = "executor.cachedPool.corePoolSize";

    /** 通用线程池:最大线程数量 */
    public static final String EXECUTOR_CACHEDPOOL_MAXIMUMPOOLSIZE = "executor.cachedPool.maximumPoolSize";

    /** 通用线程池:空闲线程保留时间(秒) */
    public static final String EXECUTOR_CACHEDPOOL_KEEPALIVETIME = "executor.cachedPool.keepAliveTime";

    /** 通用线程池:任务队列容量 */
    public static final String EXECUTOR_CACHEDPOOL_QUEUECAPACITY = "executor.cachedPool.queueCapacity";

    /** 通用线程池:线程命名格式 */
    public static final String EXECUTOR_CACHEDPOOL_NAMEFORMAT = "executor.cachedPool.nameFormat";
    
    /** 定时任务线程池:线程数量,默认值:1 */
    public static final String EXECUTOR_TIMERPOOL_COREPOOLSIZE = "executor.timerPool.corePoolSize";

    /** 定时任务线程池:线程命名格式 */
    public static final String EXECUTOR_TIMERPOOL_NAMEFORMAT = "executor.timerPool.nameFormat";
    
    /** sql2java日志:是否输出数据库操作详细异常信息 */
    public static final String SYSLOG_OP_COREDEBUG = "syslog.op.coreDebug";
    
    /** 系统日志级别 [OFF,FATAL,ERROR,WARN,INFO,DEBUG,ALL] */
    public static final String SYSLOG_LEVEL = "syslog.level";

    /** 系统日志文件位置 */
    public static final String SYSLOG_LOCATION = "syslog.location";
}
